package org.devgframwork.datasync.core.support.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.devgframwork.datasync.core.entity.ScheduleConfig;

import java.util.Map;

@Mapper
public interface ScheduleConfigMapper extends BaseMapper<ScheduleConfig> {

    @Update("update t_schedule_config set SYNC_NUM =  CASE WHEN (SYNC_NUM + #{map.syncNum}) < TOTAL_NUM THEN (SYNC_NUM + #{map.syncNum}) ELSE TOTAL_NUM END where TASK_NAME = #{map.taskName}")
    Integer updateSyncNumById(@Param(value = "map") Map<String, Object> map);

    @Update("update t_schedule_config set IS_RUNNING = 0 where ENV_NAME = #{evnName} and IS_RUNNING = 1")
    Integer updateRunning(@Param("evnName") String evnName);
}
